package com.chencs.common.lm;

import com.alibaba.fastjson.JSON;
import com.chencs.common.BaseCtr;
import com.chencs.utils.CookiesUtil;
import com.chencs.utils.JumpUtils;
import com.chencs.utils.SessionUtils;
import com.chencs.vo.biz.lianmeng.LmUser;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.RequestContextHolder;
import org.springframework.web.context.request.ServletRequestAttributes;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

@RequestMapping("/lmHome")
@RestController
public class LmHomeCtr  {
    private static final Logger logger = LoggerFactory.getLogger(LmHomeCtr.class);


    /**
     * 后台首页
     * @param session
     * @return
     */
    @RequestMapping(value = "/home", method = RequestMethod.GET)
    public ModelAndView home(HttpSession session) {
        ModelAndView modelAndView = new ModelAndView();
        LmUser user = SessionUtils.getUser(session);
        if(user==null){
            return JumpUtils.jumpLogin();
        }else{
            modelAndView.setViewName("lm/home");
        }
        return modelAndView;
    }

    /**
     * 退出
     * @param session
     * @return
     */
    @RequestMapping(value = "/LoginOut", method = RequestMethod.GET)
    public ModelAndView LoginOut(HttpSession session) {
        session.removeAttribute(SessionUtils.SESSION_USER);
        return JumpUtils.jumpLogin();

    }






}
